grammar Process0;

options {
  language = Java;
  output=AST;
  ASTLabelType=CommonTree;
}
@header {
  package process0.gen;
}
@lexer::header {
  package process0.gen;
}

process 
  : 'process'! IDENT^ '{'!
      (timeline)? 
	    (workflow|ticket|role)*
	    '}'!
  ; 

timeline
 :
	 'timeline'^ IDENT '{'!
	    (timeline)*
	 '}'!
 ;

role
  : 
    'role' IDENT'{'!
    ('permisions' '=' PERMISSIONS ';'!)? 
    ('description' '=' IDENT ';'!)? 
    '}'!
  ;

ticket
  :
    'ticket' IDENT '{'! 
      ('workflow' '=' IDENT ';'!)? 
      ('description' '=' IDENT ';'!)? 
    '}'!
  ;

workflow
  :  
    'workflow'^ IDENT '{'!
	    (action )+
	   '}'!
  ;

action 
  :
    IDENT^ '{'! 
        (states )+
        ('operations' '=' IDENT ';'!)? 
        ('permissions' '=' PERMISSIONS ';'!)? 
    '}'!
  ;

states 
  : 
    IDENT (','! b=IDENT)* '->'! IDENT^
  ;

IDENT : ('a'..'z' | 'A'..'Z')('a'..'z' | 'A'..'Z' | '0'..'9' )*;
PERMISSIONS: ('TICKET_VIEW'|'TICKET_CREATE'|'TICKET_MODIFY'|'TRAC_ADMIN');
WHITESPACE: (' '|'\t'|'\n'|'\r'|'\f')+ {$channel = HIDDEN;}; 